//
//  BFShShopCarTableViewCell.m
//  BeautyFood
//
//  Created by imac on 2020/4/26.
//  Copyright © 2020 stoneobs. All rights reserved.
//

#import "BFShShopCarTableViewCell.h"

@interface BFShShopCarTableViewCell()
@property(nonatomic, strong) UIImageView                     *icon_imageview;/**< <##> */
@property(nonatomic, strong) STLabel                     *titleLable;/**<  */
@property(nonatomic, strong) STLabel                     *priceLable;/**<  */
@property(nonatomic, strong) STLabel                     *noteLable;/**<  */
@property(nonatomic, strong) STLabel                     *postLabel;/**<  */
@end
@implementation BFShShopCarTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self stoneobs_ui_configSubView];
    }
    return self;
}
+ (CGFloat)stoneobs_ui_cell_height{
    return 124;
}
#pragma mark --configSubView
- (void)stoneobs_ui_configSubView{
    self.backgroundColor = UIColor.clearColor;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIView * whiteview = [[UIView alloc] initWithFrame:CGRectMake(10, 5, STONEOBS_UI_UISCREEN_WIDTH - 20, self.class.stoneobs_ui_cell_height - 5)];
    whiteview.backgroundColor = UIColor.whiteColor;
    whiteview.layer.cornerRadius = 4;
    whiteview.clipsToBounds = YES;
    [self.contentView addSubview:whiteview];
    
    ({
        STButton * stoneobs_ui_button = [[STButton alloc] initWithFrame:CGRectMake(10, 0, 44, 44)
                                                                  title:nil
                                                             titleColor:nil
                                                              titleFont:0
                                                           cornerRadius:0
                                                        backgroundColor:nil
                                                        backgroundImage:nil
                                                                  image:[UIImage imageNamed:@"wgx"]];
        [stoneobs_ui_button setImage:[UIImage imageNamed:@"gx"] forState:UIControlStateSelected];
        [whiteview addSubview:stoneobs_ui_button];
        stoneobs_ui_button.centerY = self.class.stoneobs_ui_cell_height/2;
        self.choseButton = stoneobs_ui_button;
    });
    
    UIImageView * stoneobs_ui_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, whiteview.height - 20, whiteview.height - 20)];
    stoneobs_ui_imageView.image =PLACE_HOLDER_IMAGE_1;
    [whiteview addSubview:stoneobs_ui_imageView];
    self.icon_imageview = stoneobs_ui_imageView;
    stoneobs_ui_imageView.left = self.choseButton.right;
    
    CGFloat maxwitdh = whiteview.width  - 20 - self.icon_imageview.right;
    ({
        STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(self.icon_imageview.right+10, 10, maxwitdh, 33)
                                                                text:@"[可口可乐] 汽水 碳酸饮料"
                                                           textColor:STONEOBS_UI_FIRST_TEXT_COLOR
                                                                font:13
                                                         isSizetoFit:NO
                                                       textAlignment:NSTextAlignmentLeft];
        [whiteview addSubview:stoneobs_ui_label];
        self.titleLable = stoneobs_ui_label;
        
    });
    

    ({
        STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(self.icon_imageview.right+10, 10, maxwitdh, 20)
                                                                text:@" （6 x 24瓶 x 300ml） "
                                                           textColor:STONEOBS_UI_SECEND_TEXT_COLOR
                                                                font:10
                                                         isSizetoFit:NO
                                                       textAlignment:NSTextAlignmentLeft];
        [whiteview addSubview:stoneobs_ui_label];
        stoneobs_ui_label.centerY = self.icon_imageview.centerY;
        self.noteLable = stoneobs_ui_label;
        
    });
    
    ({
        STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(self.icon_imageview.right+10, 10, maxwitdh, 20)
                                                                text:@"¥123/箱"
                                                           textColor:WH_UICOLOR_FROM_RGBA(0xFF2F3D)
                                                                font:15
                                                         isSizetoFit:NO
                                                       textAlignment:NSTextAlignmentLeft];
        [whiteview addSubview:stoneobs_ui_label];
        stoneobs_ui_label.left = self.noteLable.left;
        stoneobs_ui_label.centerY = self.noteLable.centerY;
        self.priceLable = stoneobs_ui_label;
        self.priceLable.bottom = whiteview.height - 20;
        
        self.add_view = [[STTools_AutoAddView alloc] initWithFrame:CGRectMake(0, 0, 22 * 3, 22)];
        self.add_view.right = whiteview.width - 10;
        self.add_view.centerY = self.priceLable.centerY;
        [whiteview addSubview:self.add_view];
        self.add_view.textFiled.userInteractionEnabled = YES;
    });
    
    ({
        STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(self.icon_imageview.right+10, 10, maxwitdh, 20)
                                                                text:@" （6 x 24瓶 x 300ml） "
                                                           textColor:FlatRed
                                                                font:10
                                                         isSizetoFit:NO
                                                       textAlignment:NSTextAlignmentRight];
//        [whiteview addSubview:stoneobs_ui_label];
        stoneobs_ui_label.bottom = whiteview.height;
        stoneobs_ui_label.right = whiteview.width-10;
        self.postLabel = stoneobs_ui_label;
        
    });
    
    
}
- (void)setCarModel:(BFShShopCarModel *)carModel{
    _carModel = carModel;
    self.choseButton.selected  = carModel.cus_selected;
    self.add_view.textFiled.text = @(carModel.num).description;
    [self.icon_imageview sd_setImageWithURL:carModel.goods_img.mj_url placeholderImage:PLACE_HOLDER_IMAGE_1];
    self.titleLable.text = carModel.goods_name;
    
    self.noteLable.text = [NSString stringWithFormat:@"%@%@",carModel.type_name,carModel.goods_spec];
    [NSString stoneobs_fun_lableAutoAdjustWitdhWithLabel:self.noteLable];
    self.noteLable.width = self.noteLable.width + self.noteLable.height;


    
    self.priceLable.text = [NSString stringWithFormat:@"￥%0.2f",carModel.goods_price];
    
//    self.postLabel.text =[NSString stringWithFormat:@"满%0.1f包邮",carModel.free_postage];
}
@end
